using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TablePetExpDao:DaoBase<TablePetExp>
    {
        public override void AddPrimaryIndex(TablePetExp model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TablePetExp.txt";
        }

        protected override TablePetExp ParseRowData(string[] rowData)
        {
            TablePetExp data = new TablePetExp();
			data.id = rowData [0];

            if (string.IsNullOrEmpty(rowData[1]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[1]);
            }

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.level = 0;
            }
            else
            {
                data.level = int.Parse(rowData[2]);
            }

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.exp = 0;
            }
            else
            {
                data.exp = int.Parse(rowData[3]);
            }

            return data;
        }


        public override void AddOneIndex(TablePetExp model)
        {
            if (!cacheOneIndex.ContainsKey(model.quality.ToString()))
            {
                cacheOneIndex[model.quality.ToString()] = new List<TablePetExp>();
            }
            cacheOneIndex[model.quality.ToString()].Add(model);
        }
    

    }

}
